package GameEngine.Animation.Translation;

import processing.core.PImage;
import GameEngine.helper.PAppletBridge;

public class ImageTranslation extends Translation {
	private PImage Img;

	public ImageTranslation(int size, String fname) {
		super(size);
		Img = PAppletBridge.loadImage(fname);
	}
	
	
	public ImageTranslation(int size, PImage image) {
		super(size);
		Img = image;
	}


	public void draw(int fn) {
		if (fn < Frames.length) {
			if (Frames[fn] != null) {
				KeyFrame kf = Frames[fn];

				PAppletBridge.pushMatrix();

				PAppletBridge.imageMode(kf.getImageMode());
				PAppletBridge.translate(kf.getPosX(), kf.getPosY());
				PAppletBridge.rotate(PAppletBridge.radians(kf.getAngle()));
				PAppletBridge.tint(255, kf.getAlpha());

				PAppletBridge.image(Img, 0, 0,
						(int) (kf.getScaleX() * Img.width), (int) (kf
								.getScaleY() * Img.height));
				
				PAppletBridge.noTint();

				PAppletBridge.popMatrix();
			}
		}
	}

}
